﻿// We begin with the constructor
function Circle(radius) {
    // r is an instance property, defined and initialized in the constructor.
    this.r = radius;
}

// Circle.PI is a class property--it is a property of the constructor function.
Circle.PI = 3.14159;

// Here is an instance method that computes a circle's area.
Circle.prototype.area = function () { return Circle.PI * this.r * this.r; }

// This class method takes two Circle objects and returns the
// one that has the larger radius.
Circle.max = function (a, b) {
    if (a.r > b.r) return a;
    else return b;
}

Circle.prototype.toString = function () {
    return "Circle of radius: " + this.r + ", area: " + this.area();
}
